/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.Dialogos;

import Logica.EManager;
import Objetos.Cliente;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author jose
 */
public class DialogoInformeUsuario extends javax.swing.JDialog {
    
    /**
     * Creates new form DialogoInformeUsuario
     */
    public DialogoInformeUsuario(Cliente cliente, EManager gestor) {
        this.cliente=cliente;
        this.gestor=gestor;
        initComponents();
        panelContenido.setVisible(true);
        initDatos();
    }

    private void initDatos()
    {
        Calendar calendario = Calendar.getInstance();
        String mediaAnual=String.valueOf(gestor.getInformeAnho("2012",cliente));
        lblMediaAnho.setText(mediaAnual);
        String mesActual=String.valueOf(gestor.getInformeMes("2012",Integer.toString(calendario.get(Calendar.MONTH)),cliente));
        lblAnhoActual.setText(mesActual);
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelContenido = new javax.swing.JPanel();
        panelMensual = new javax.swing.JPanel();
        panelMensualDatos = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        lblInformaMesAnhoAnterior = new javax.swing.JLabel();
        lblAnhoAnterior = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        lblInformaMesAnhoActual = new javax.swing.JLabel();
        lblAnhoActual = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        lblInformaMediaAnho = new javax.swing.JLabel();
        lblMediaAnho = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        panelMensualSeleccion = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        panelContenido.setLayout(new java.awt.CardLayout());

        panelMensual.setLayout(new java.awt.BorderLayout());

        panelMensualDatos.setLayout(new java.awt.GridLayout(1, 0));

        lblInformaMesAnhoAnterior.setText("Mes seleccionado");

        lblAnhoAnterior.setFont(new java.awt.Font("Cantarell", 1, 24)); // NOI18N
        lblAnhoAnterior.setText("N/D");

        jLabel4.setText("KW");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(90, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(lblAnhoAnterior)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addGap(23, 23, 23))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(lblInformaMesAnhoAnterior)
                        .addContainerGap())))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(27, Short.MAX_VALUE)
                .addComponent(lblInformaMesAnhoAnterior)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblAnhoAnterior)
                    .addComponent(jLabel4))
                .addGap(27, 27, 27))
        );

        panelMensualDatos.add(jPanel4);

        lblInformaMesAnhoActual.setText("Mes actual");

        lblAnhoActual.setFont(new java.awt.Font("Cantarell", 1, 24)); // NOI18N
        lblAnhoActual.setText("N/D");

        jLabel6.setText("KW");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(86, 86, 86)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblInformaMesAnhoActual)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(lblAnhoActual)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6)))
                .addContainerGap(55, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(lblInformaMesAnhoActual)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblAnhoActual)
                    .addComponent(jLabel6))
                .addContainerGap(28, Short.MAX_VALUE))
        );

        panelMensualDatos.add(jPanel5);

        lblInformaMediaAnho.setText("Media consumo");

        lblMediaAnho.setFont(new java.awt.Font("Cantarell", 1, 24)); // NOI18N
        lblMediaAnho.setText("N/D");

        jLabel7.setText("KW");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(53, 53, 53)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblInformaMediaAnho)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(lblMediaAnho)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7)))
                .addContainerGap(65, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(lblInformaMediaAnho)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblMediaAnho)
                    .addComponent(jLabel7))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        panelMensualDatos.add(jPanel2);

        panelMensual.add(panelMensualDatos, java.awt.BorderLayout.PAGE_END);

        jLabel2.setText("Selecciona el mes:");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"}));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelMensualSeleccionLayout = new javax.swing.GroupLayout(panelMensualSeleccion);
        panelMensualSeleccion.setLayout(panelMensualSeleccionLayout);
        panelMensualSeleccionLayout.setHorizontalGroup(
            panelMensualSeleccionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelMensualSeleccionLayout.createSequentialGroup()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        panelMensualSeleccionLayout.setVerticalGroup(
            panelMensualSeleccionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMensualSeleccionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelMensualSeleccionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelMensual.add(panelMensualSeleccion, java.awt.BorderLayout.PAGE_START);

        panelContenido.add(panelMensual, "card2");

        getContentPane().add(panelContenido, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
                String mesElegido=String.valueOf(gestor.getInformeMes("2012",String.valueOf(jComboBox1.getSelectedIndex()+1),cliente));
                lblAnhoAnterior.setText(mesElegido);
    }//GEN-LAST:event_jComboBox1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JLabel lblAnhoActual;
    private javax.swing.JLabel lblAnhoAnterior;
    private javax.swing.JLabel lblInformaMediaAnho;
    private javax.swing.JLabel lblInformaMesAnhoActual;
    private javax.swing.JLabel lblInformaMesAnhoAnterior;
    private javax.swing.JLabel lblMediaAnho;
    private javax.swing.JPanel panelContenido;
    private javax.swing.JPanel panelMensual;
    private javax.swing.JPanel panelMensualDatos;
    private javax.swing.JPanel panelMensualSeleccion;
    // End of variables declaration//GEN-END:variables
    private Cliente cliente;
    private EManager gestor;


}
